<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="menu" content="assetMenu" />
<meta name="nav" content="1" />
<meta name="acc" content="0-0-0" />
<title>车辆管理</title>
<link rel='stylesheet' type='text/css' href='${ctx}/scripts/fullcalendar/fullcalendar.css' />
<link rel='stylesheet' type='text/css' href='${ctx}/scripts/fullcalendar/fullcalendar.print.css' media='print' />
<script type='text/javascript' src='${ctx}/scripts/fullcalendar/fullcalendar.js'></script>
<!--  通用情况下 不引入 js css  表单验证  js 放置到页面中 -->
<script>
		
		$(document).ready(function() {
			 $("input[name='startDate']").addClass("Wate").bind("focus", function(){
	    	 WdatePicker({skin:'whyGreen',minDate:'1900-10-01',maxDate:'#F{$dp.$D(\'useEnd\')||\'%y-%M-%d\'}',dateFmt:'yyyy-MM-dd HH:mm:ss'});});
			 $("input[name='finishDate']").addClass("Wate").bind("focus", function(){
	    	 WdatePicker({skin:'whyGreen',minDate:'#F{$dp.$D(\'useBegin\')}',dateFmt:'yyyy-MM-dd HH:mm:ss'});});
		 //调用checkRadio
		 checkRadio();
		 //赋值radio
		 $("#whetherbycar").click(function(){
			 if($("#whetherbycar").attr("checked")){
				 $("#whetherbycar").val("1");	
 				}
		 });
		 $("#inputForm").validate({
			 rules: {
				  howManyPeople: {
						required: true,
						digits: true,
						max:10
					}
		 		},
		 		messages: {
		 			howManyPeople: {
						required: "必须填写！",
						digits: "必须输入数字！",
						max:"最大值不能超过10"
					}
		 		}
		 });
		 
		
		});
		//弹出车辆选择窗体
		function choose(){
			
			var starttime = $("#useBegin").val();
			var endtime = $("#useEnd").val();
			if(starttime==""){
				alert("请输入开始时间！");
				return false;
			}
			if(endtime==""){
				alert("请输入结束时间！");
				return false;
			}
		    var orgId = $("input[name='CARID']").val();
			var url = "${ctx}/asset/car/api/information!findNoUserCar.action?starttime=" + starttime + "&endtime=" + endtime;
		
			var obj = new Object();
		    mm = showDialogWindow(url);
			if (mm != null) {
				$("#carId").val(mm.carId);
				$("input[name='choicecar']").val(mm.choicecar);
			}
		    ch();
	   }
		//遍历radio 
		function checkRadio(){
			//获得radio集合
			var directionsList = $("input[name=directions]");
			for(var i =0;i<directionsList.length;i++){
				if(directionsList[i].value=="${directions}")	
					directionsList[i].checked="checked";
			  }
			if("${whetherbycar}"==1){
				$("#whetherbycar").val("1");
				$("#whetherbycar").attr("checked","checked");
			}
		}
	</script>
	<script type='text/javascript'>
	var ad = '${id}';
	if(ad!=""){
    $(document).ready(function() {
        $('#calendar').fullCalendar({
        	 height: 200,
        header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
                editable: true,
                events: "${ctx}/asset/car/record!getOneCarRecordToJson.action?id=${id}"
        });
    });
	}else {
		$(document).ready(function() {
	        $('#calendar').fullCalendar({
	        	 height: 200,
	        header: {
	                left: 'prev,next today',
	                center: 'title',
	                right: 'month,agendaWeek,agendaDay'
	            },
	            editable: true,
	            events: "${ctx}/asset/car/record!getAllRecordToJson.action"
	        });
	    });
	}
	function ch(){
		var cardid = $('#carId').attr("value");
		$('#calendar').html("");
	    $('#calendar').fullCalendar({
    	 height: 200,
    header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        editable: true,
        
        events: "${ctx}/asset/car/record!getOneRecToJsonByCardId.action?id="+cardid
    });
  }
</script>
<style type='text/css'>
	#calendar {
	    position:relative;
		margin: 0 1em 1em 1em;
		}
</style>
</head>

<body>
<div id='calendar'></div>
<form action="${ctx }/asset/assets/record!save.action" method="post" id="inputForm" class="yform">
<div id="caption" ><h5>资产使用记录</h5></div>
<table class="noborder" border="0">
	<tr>
		<td>说明：</td>
		<td><input type="radio" name="directions" value="正常" />正常 <input
			type="radio" name="directions" value="紧急" />紧急 <input type="radio"
			name="directions" value="重要" />重要</td>
		<td>是否自驾</td>
		<td><input type="radio" id="whetherbycar" name="whetherbycar"
			value="0" /> 申请自驾</td>
	</tr>
	<tr>
		<td>使用人</td>
		<td><input type="hidden" name="id" value="${id}" /> <input
			type="text" name="userId" value="${userId}" /></td>
		<td>使用人数</td>
		<td><input type="text" name="howManyPeople"
			value="${howManyPeople }" /></td>
	</tr>
	<tr>
		<td>开始时间</td>
		<td><input type="text" id="useBegin" name="startDate"
			value="${startDate }" readonly="readonly" /></td>
		<td>结束时间</td>
		<td><input type="text" id="useEnd" name="finishDate"
			value="${finishDate }" readonly="readonly" /></td>
	</tr>
	<tr>
		<td>目的地</td>
		<td><input type="text" name="destination" value="${destination}" />
		</td>
		<td>车辆选择</td>
		<td><input type="hidden" id="carId" name="CARID"
			value="${carInformation.id}" />
			 <input type="text" id="choicecar" name="choicecar" value="${carInformation.licenseplateNumber}" readonly="readonly" /> 
			 <input type="button" id="useCar" value="选择" onclick="choose();" />
			 </td>
	</tr>
	<tr>
		<td>代理人部门</td>
		<td><input type="text" name="department" value="${department}" />
		</td>
		<td>代理人</td>
		<td><input type="text" name="agent" value="${agent }" /></td>
	</tr>
	<tr>
		<td>备注</td>
		<td colspan="3"><input type="text" name="remark"
			value="${remark}" /></td>
	</tr>
</table>
<div class="type-button"><input align="bottom" type="submit" class="submit" value="保存" />
			<input align="bottom" type="button" class="reset" value="返回" onclick="history.back();" />
		</div>
</form>
</body>
</html>
